﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace Ext.Net.UIS
{

    public class NumberField : Ext.Net.NumberField, ITermBox
    {
        public new Context Context { get; set; }
        public Term Term { get; set; }
        public TermNode ParentTermNode { get; set; }
        public TermNode TermNode { get; set; }

        public bool ControlsCreated { get; set; }
        public void CreateControls(UisCreateControlArgs e)
        {
            this.UisGetTermNode();
            if (TermNode == null) return;

            TermNode.ApplyToField(this);
            TermNode.ApplyListeners(Listeners);
            this.UisAddTermNodeConfigItem();
        }

        [DefaultValue(typeof(Unit), "60")]
        public override Unit Width
        {
            get { return UnitPixelTypeCheck(ViewState["Width"], 60, "Width"); }
            set { base.Width = value; }
        }
    }




    public class FloatField : NumberField
    {
        [DefaultValue(-1)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", -1); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float1Field : NumberField
    {
        [DefaultValue(1)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 1); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float2Field : NumberField
    {
        [DefaultValue(2)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 2); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float3Field : NumberField
    {
        [DefaultValue(3)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 3); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float4Field : NumberField
    {
        [DefaultValue(4)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 4); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float5Field : NumberField
    {
        [DefaultValue(5)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 5); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float6Field : NumberField
    {
        [DefaultValue(6)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 6); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float7Field : NumberField
    {
        [DefaultValue(7)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 7); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float8Field : NumberField
    {
        [DefaultValue(8)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 8); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float9Field : NumberField
    {
        [DefaultValue(9)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 9); }
            set { base.DecimalPrecision = value; }
        }
    }

    public class Float10Field : NumberField
    {
        [DefaultValue(10)]
        public override int DecimalPrecision
        {
            get { return State.Get("DecimalPrecision", 10); }
            set { base.DecimalPrecision = value; }
        }
    }


    public class IntField : NumberField
    {
        public override bool AllowDecimals { get { return false; } set { } }

        [DefaultValue(int.MaxValue)]
        public override double MaxValue
        {
            get { return State.Get<double>("MaxValue", int.MaxValue); }
            set { base.MaxValue = value; }
        }

        [DefaultValue(int.MinValue)]
        public override double MinValue
        {
            get { return State.Get<double>("MinValue", int.MinValue); }
            set { base.MinValue = value; }
        }
    }

    public class UIntField : IntField
    {
        [DefaultValue(0)]
        public override double MinValue
        {
            get { return State.Get<double>("MinValue", 0); }
            set { base.MinValue = value; }
        }
    }

    public class PercField : NumberField
    {
        [DefaultValue(100)]
        public override double MaxValue
        {
            get { return State.Get<double>("MaxValue", 100); }
            set { base.MaxValue = value; }
        }

        [DefaultValue(0)]
        public override double MinValue
        {
            get { return State.Get<double>("MinValue", 0); }
            set { base.MinValue = value; }
        }
    }


}
